import java.util.ArrayList;
import java.util.List;

import sketch.JavaSource;
import sketch.MethodChoice;
import sketch.OracleChoice;
import sketch.Sketch;
import sketch.SketchSequence;
import sketch.ValueChoice;
import sketch.generator.GenTests;
import sketch.generator.SequenceGenerator;
import sketch.generator.ValueGenerator;
import sketch.subject.TreeMap;
import junit.framework.TestCase;


public class TreeMapTestSketch extends TestCase {

	//question on objects, where did objects come from??
	//convert to sequence? a random style pool?
	//
	@Sketch
	public void testTreeMap() {
		/***
		 * Reset the global
		 * */
		String testPath = "/scratch/eclipseworkspace/SketchSeq/examples/TreeMapSketchExecution.java";
		GenTests genTests = new GenTests(testPath);
		GenTests.reset(TreeMap.class);
		
		//--------------------------------------------------------------------//
		
		//program in Java
		@JavaSource
		TreeMap tree = new TreeMap();
		
		//suppose we could fetch the above
		//XXX
		SequenceGenerator<? extends Object> initGenerator
//		    = MethodChoice.choose(tree/*null for init state*/, "<init>");
		    = MethodChoice.construct(TreeMap.class);
		
		//program in the given language!
		ValueGenerator<Integer> intPool = ValueChoice.getIntRange(1, 4);
		SequenceGenerator<? extends Object> putGenerator
		    = MethodChoice.permute(tree, "put(int)", intPool);
		
		//testing oracle
		SequenceGenerator<? extends Object> containKeyGenerator1
		    = OracleChoice.observeMethodOutput(tree, "containsKey(int)", intPool, true);
		
		ValueGenerator<?> removeArgs = ValueChoice.randomChoose(3, intPool);
		SequenceGenerator<? extends Object> removeGenerator
		    = MethodChoice.inorder(tree, "remove(int)", removeArgs);
		
		//XXX object state
		ValueGenerator<?> containArgs = ValueChoice.randomChoose(3, intPool);
		SequenceGenerator<? extends Object> observeKeyGenerator
		    = OracleChoice.observeMethodOutput(tree, "containsKey(int)", containArgs, false);
		
		//XXX object state
		ValueGenerator<?> containArg2 = ValueChoice.randomChoose(3, intPool);
		ValueGenerator<?> remainArgs = ValueChoice.removeValues(intPool, containArg2);
		SequenceGenerator<? extends Object> containKeyGenerator2
		    = OracleChoice.observeMethodOutput(tree, "containsKey(int)", remainArgs, true);
		
		SequenceGenerator<? extends Object> printGenerator = MethodChoice.choose(tree, "print()");
		
		SequenceGenerator<? extends Object> sizeGenerator
		    = OracleChoice.observeMethodOutput(tree, "size()", 1);
		SequenceGenerator<? extends Object> concreteStringGenerator
		    = OracleChoice.observeMethodOutput(tree, "concreteString(int)", ValueChoice.getIntRange(1, 1));
		SequenceGenerator<? extends Object> toStringGenerator
		    = OracleChoice.observeMethodOutput(tree, "toString()");
		
		//--------------------------------------------------------------------//
		/**
		 * Gen Tests
		 * **/
		genTests.addGenerator(initGenerator);
		genTests.addGenerator(putGenerator);
		genTests.addGenerator(containKeyGenerator1);
		genTests.addGenerator(removeGenerator);
		genTests.addGenerator(observeKeyGenerator);
		genTests.addGenerator(containKeyGenerator2);
		genTests.addGenerator(printGenerator);
		genTests.addGenerator(sizeGenerator);
		genTests.addGenerator(concreteStringGenerator);
		genTests.addGenerator(toStringGenerator);
		genTests.genTests();
		
		//List<String>[] lsa = new List<String>[10];
//		
		{@JavaSource
		  TreeMap tree1 = new TreeMap();
		}
		
		{@JavaSource
			  TreeMap tree1 = new TreeMap();
		}
		
		{@JavaSource
			  TreeMap tree1 = new TreeMap();
		}
	}
	
//	@Sketch
//	public void testTreeMapSymbc() {
//		/***
//		 * Reset the global
//		 * */
//		GenTests genTests = new GenTests();
//		genTests.reset();
//		//--------------------------------------------------------------------//
//		@JavaSource
//		TreeMap tree = new TreeMap();
//		
//		SequenceGenerator<? extends Object> putGenerator =
//			MethodChoice.inorder(tree, "put(int)", ValueChoice.getPoolWithIntHoles(3));
//		SequenceGenerator<? extends Object> removeGenerator =
//			MethodChoice.inorder(tree, "remove(int)", ValueChoice.getPoolWithIntHoles(2));
//		SequenceGenerator<? extends Object> sizeGenerator = OracleChoice.observeMethodOutput(tree, "size()");
//		
//		//--------------------------------------------------------------------//
//		/**
//		 * Gen Tests
//		 * **/
//		genTests.addGenerator(putGenerator);
//		genTests.addGenerator(removeGenerator);
//		genTests.addGenerator(sizeGenerator);
//		genTests.genTests();
//	}
//	
//	//a concrete test
//	public void testConcreteTreeMap() {
//		TreeMap treeMap = new TreeMap();
//		
//		treeMap.put(1);
//		assertTrue("Tree map should contain key",
//				treeMap.containsKey(1));
//		
//		treeMap.remove(1);
//		assertTrue("Tree map should not contain key",
//				!treeMap.containsKey(1));
//		assertTrue(treeMap.size() == 0);
//		
//		treeMap.print();
//
//		assertTrue("".equals(treeMap.concreteString(0)));
//		assertTrue("".equals(treeMap.toString()));
//	}
//	
//	public void testTreeMapExample() {
//		TreeMap tree = new TreeMap();
//		
//		//repeat
//		//permute put with values 1 -- 6
//		tree.put(1);
//		tree.put(2);
//		//repeat
//		//permute remove with values 2, 4, 5
//		tree.remove(2);
//		tree.remove(4);
//		//permute remove with values 2, 5, 6
//		tree.toString();
//		
//		//oracle
//		
//	}
	
}
